<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>medic</title>
    <link rel="stylesheet" href="/Trees/LayUiBac/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-container">
    <div class="layui-row" style="border: cadetblue 1px solid;padding: 20px;margin-top: 30px">
        <h1>药剂器械出库管理</h1>
        <table id="demo" lay-filter="medicTable"></table>

        <div class="layui-col-md4" style="border: cadetblue 1px solid;padding: 20px">
            <input type="text" name="title" required lay-verify="required" id="className" placeholder="领用的小班"
                   autocomplete="off" class="layui-input" width="100px">
            <br>
            <label class="layui-form-label">起始时间</label>
            <input type="text" class="layui-input" id="date1" style="width: 100px">
            <br>
            <label class="layui-form-label">结束时间</label>
            <input type="text" class="layui-input" id="date2" style="width: 100px">
            <br>
            <div class="layui-col-md12">
                <button class="layui-btn" type="button" id="Find">查询</button>
                <button class="layui-btn layui-bg-orange" type="button" id="buttonAdd">快速添加新的出库信息</button>
            </div>
        </div>
    </div>
</div>


<script src="/Trees/LayUiBac/layui/layui.js"></script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">查看详情</a>
</script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#date1' //指定元素
        });

        laydate.render({
            elem: '#date2'
        })
    });
</script>

<script>
    layui.use('table', function () {
        let $ = layui.$;
        let layer = layui.layer;
        let table = layui.table;
        //第一个实例
        let show = table.render({
            elem: '#demo'
            , url: '/Trees/medicOut' //数据接口
            , page: true //开启分页
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "count": res.total, //解析数据长度
                    "data": res.list
                };
            }
            , cols: [[ //表头
                // {field: 'pkId', title: 'ID'}
                // ,
                {field: 'people', title: '出库人'}
                , {field: 'time', title: '日期'}
                , {field: 'className', title: '领用小班',templet:function (d) {
                        return d.tClass.className;
                    }}
                ,{field:'name',title:'领用物品'}
                ,{field:'number',title:'领用物品数量'}
                ,{field:'type',title:'所属类型'}
                ,{field:'control',title:'应对类型'}
            ]]
        });
        $('#Find').on('click', function () {
            show.reload({
                where: {
                    // mouseName: $('#mouseName').val()
                    date1:$('#date1').val()
                    ,date2:$('#date2').val()
                    ,className:$('#className').val()
                }
                , page: {
                    curr: 1
                }
            })
        })

        $('#buttonAdd').on('click', function () {
            let a, b, c, d, e, f;
            layer.open({
                type: 2
                , content: "/Trees/LayUiBac/home/medic/Jump/add.html"//填一个url地址
                // , content: "/Trees/LayUiBac/home/medic/Jump/addMedicOut.html"//填一个url地址
                , area: ['600px', '600px']
                , shade: ['0.9', '#393D49']
                , anim: 0
                , maxmin: true
                , btn: ["确认提交"]
                , yes: function (index, layero) {
                    let body = layer.getChildFrame('body', index);
                    a = body.find("select[name=medicName]").val();
                    b = body.find("select[name=number]").val();
                    c = body.find("select[name=control]").val();
                    d = body.find("select[name=className]").val();
                    e = body.find("select[name=type]").val();
                    let strs = "&medicName=" + a + "&number=" + b + "&control=" + c + "&className=" + d+"&type="+e
                    console.log(strs)
                    $.ajax({
                        type: "post",
                        url: "/Trees/medicOut?method=add" + strs
                    })

                    layer.close(index);
                    show.reload();
                }
                , success: function (layero, index) {

                }

            })
        })
    });


</script>


</body>
</html>